package com.yunxin.core.infra.persistence.mapper.product;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.yunxin.core.infra.persistence.entity.product.ProductAdvanceChargeRecordDO;
import com.yunxin.core.infra.persistence.entity.product.query.result.AdvanceChargeResult;
import com.yunxin.core.infra.persistence.entity.product.query.result.ProductAdvanceChargeRecordStatisticsResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * @author zero°
 * @since 2023-12-16
 */
@DS("core")
@Mapper
public interface ProductAdvanceChargeRecordExtendMapper extends ProductAdvanceChargeRecordMapper {

    /**
     * 分页查询渠道预付款记录列表总条数
     *
     * @param merchantId             merchantId
     * @param productId              productId
     * @param startAdvanceChargeDate startAdvanceChargeDate
     * @param endAdvanceChargeDate   endAdvanceChargeDate
     * @return long
     */
    long countProductAdvanceChargeRecordPageQuery(@Param("merchantId") Long merchantId,
                                                  @Param("productId") Long productId,
                                                  @Param("startAdvanceChargeDate") Date startAdvanceChargeDate,
                                                  @Param("endAdvanceChargeDate") Date endAdvanceChargeDate);

    /**
     * 分页查询渠道预付款记录列表
     *
     * @param merchantId             merchantId
     * @param productId              productId
     * @param startAdvanceChargeDate startAdvanceChargeDate
     * @param endAdvanceChargeDate   endAdvanceChargeDate
     * @param offset                 offset
     * @param pageSize               pageSize
     * @return List<ProductAdvanceChargeRecordDO>
     */
    List<ProductAdvanceChargeRecordDO> productAdvanceChargeRecordPageQuery(@Param("merchantId") Long merchantId,
                                                                           @Param("productId") Long productId,
                                                                           @Param("startAdvanceChargeDate") Date startAdvanceChargeDate,
                                                                           @Param("endAdvanceChargeDate") Date endAdvanceChargeDate,
                                                                           @Param("offset") int offset,
                                                                           @Param("pageSize") int pageSize);

    /**
     * 统计结算数量
     *
     * @param merchantId             merchantId
     * @param productId              productId
     * @param startAdvanceChargeDate startAdvanceChargeDate
     * @param endAdvanceChargeDate   endAdvanceChargeDate
     * @return List<ProductAdvanceChargeRecordDO>
     */
    long productAdvanceChargeRecordSettlementNumberCountQuery(@Param("merchantId") Long merchantId,
                                                                           @Param("productId") Long productId,
                                                                           @Param("startAdvanceChargeDate") Date startAdvanceChargeDate,
                                                                           @Param("endAdvanceChargeDate") Date endAdvanceChargeDate);

    /**
     * 查询渠道预付款记录统计
     *
     * @param merchantId             merchantId
     * @param productId              productId
     * @param startAdvanceChargeDate startAdvanceChargeDate
     * @param endAdvanceChargeDate   endAdvanceChargeDate
     * @return long
     */
    ProductAdvanceChargeRecordStatisticsResult productAdvanceChargeRecordStatistics(@Param("merchantId") Long merchantId,
                                                                                    @Param("productId") Long productId,
                                                                                    @Param("startAdvanceChargeDate") Date startAdvanceChargeDate,
                                                                                    @Param("endAdvanceChargeDate") Date endAdvanceChargeDate);

    /**
     * 查询渠道预付款列表
     * @param merchantIds merchantIds
     * @return  List<AdvanceChargeResult>
     */
    List<AdvanceChargeResult> listAdvanceChargeResultByMerchantIds(@Param("merchantIds") Set<Long> merchantIds);
}
